<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="model.*"%>
<%@page import="model.sets.*"%>
<%@page import="db.DAOFactory"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Scene-map</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="/travelProject/resources/styles.css">
  </head>
  
  <body>
  	<% request.setCharacterEncoding("utf-8"); %>
    <div id="info">
		<input type="text" value="输入你要查询的关键字"/><input type="button" value="搜索景点"/>

	<%
			out.print("<p>point------------------------<p>");
			ArrayList<Point> pointList=null;
			Point point=null;	
			
			point = DAOFactory.getPointDAO().findById(1);
			out.print("<p>object:"+point.getName()+"<p>");
			pointList=DAOFactory.getPointDAO().findByKeyword("码头","描");
			for(Iterator i=pointList.iterator();i.hasNext();){
		out.print("<p>list:"+((Point)i.next()).getName()+"<p>");
			}
			User user=DAOFactory.getUserDAO().findById(1);
			Point newPoint=new Point();
			newPoint.setId(10000);
			newPoint.setName("haha");
			newPoint.setXpos(0);
			newPoint.setYpos(0);
			newPoint.setHead(point);
			newPoint.setDescription("new");
			newPoint.setPrice(500) ;
			newPoint.setUrl("");
			newPoint.setUser(user);
			DAOFactory.getPointDAO().save(newPoint);
			point = DAOFactory.getPointDAO().findById(10000);
			out.print("<p>save select:"+point.getName()+"<p>");
			DAOFactory.getPointDAO().delete(10000);	
			point = DAOFactory.getPointDAO().findById(10000);
			if(point!=null)	
		out.print("<p>delete select:"+point.getName()+"<p>");
			else
		out.print("<p>delete select:null<p>");
			
			out.print("<p>action------------------------<p>");
			ArrayList<Action> actionList=null;
			Action action=null;	
			
			action = DAOFactory.getActionDAO().findById(1);
			out.print("<p>object:"+action.getName()+"<p>");
			actionList=DAOFactory.getActionDAO().findAll();
			if(!actionList.isEmpty())
		for(Iterator i=actionList.iterator();i.hasNext();){
			action=(Action)i.next();
			out.print("<p>list id:"+action.getId()+"<p>");
			out.print("<p>list name:"+action.getName()+"<p>");
		}
			Action newAction=new Action();
			newAction.setName("添加旅游路线");
			//DAOFactory.getActionDAO().save(newAction);
			action = DAOFactory.getActionDAO().findById(12);
			out.print("save select:"+action.getName()+"\n");
			//DAOFactory.getActionDAO().delete(11);		
			action = DAOFactory.getActionDAO().findById(2);
			if(action!=null){	
		out.print("<p>delete select id:"+action.getId()+"<p>");
		out.print("<p>delete select name:"+action.getName()+"<p>");
			}else
		out.print("<p>delete select:null<p>");
		
			out.print("<p>Priority------------------------<p>");
			ArrayList<Priority> List1=null;
			Priority object1=null;	
			
			object1 = DAOFactory.getPriorityDAO().findById(1);
			out.print("<p>object:"+object1.getName()+"<p>");
			List1=DAOFactory.getPriorityDAO().findAll();
			if(!List1.isEmpty())
		for(Iterator i=List1.iterator();i.hasNext();){
			object1=(Priority)i.next();
			out.print("<p>list id:"+object1.getId()+"<p>");
			out.print("<p>list name:"+object1.getName()+"<p>");
		}
			Priority object2=new Priority();
			object2.setName("haha");
			//DAOFactory.getPriorityDAO().save(object2);
			//action = DAOFactory.getActionDAO().findById(2);
			//out.print("save select:"+action.getName()+"\n");
			//DAOFactory.getPriorityDAO().delete(2);		
			object1 = DAOFactory.getPriorityDAO().findById(3);
			if(object1!=null){	
		out.print("<p>delete select id:"+object1.getId()+"<p>");
		out.print("<p>delete select name:"+object1.getName()+"<p>");
			}else
		out.print("<p>delete select:null<p>");
		
			out.print("<p>paset------------------------<p>");
			String name=DAOFactory.getPASetDAO().findById(1,1).getAction().getName();
			out.print("<p>select name:"+name+"<p>");
			action = DAOFactory.getActionDAO().findById(13);
			PASet paset=new PASet();
			paset.setAction(action);
			paset.setPriority(1);
			DAOFactory.getPASetDAO().save(paset);
			name=DAOFactory.getPASetDAO().findById(1,13).getAction().getName();
			out.print("<p>save select name:"+name+"<p>");
			ArrayList<Action> actionList2=DAOFactory.getPASetDAO().findByPriorityId(1);
			if(!actionList2.isEmpty())
		for(Iterator i=actionList2.iterator();i.hasNext();){
			action=(Action)i.next();
			out.print("<p>action list id:"+action.getId()+"<p>");
			out.print("<p>action list name:"+action.getName()+"<p>");
		}
		DAOFactory.getPASetDAO().delete(1,13);
			if(DAOFactory.getPASetDAO().delete(1,13))
		out.print("<p>delete ok!<p>");
			PASet paset1=DAOFactory.getPASetDAO().findById(1,13);
			if(paset1!=null){
		name=paset1.getAction().getName();
		out.print("<p>delete select name:"+name+"<p>");
			}else
		out.print("<p>delete select name:null<p>");
			
			
			out.print("<p>user------------------------<p>");
			ArrayList<Activity> activityList=null;
			Activity activity=null;
			//activity=DAOFactory.getActivityDAO().findById(1);
	%>
    </div>
  </body>
</html>
